#ifndef NR_OBJECT_H
#define NR_OBJECT_H

#include <QObject>
#include "nr_std.h"

class nr_object : public QObject
{
    Q_OBJECT
public:
    nr_object(QObject *parent = NULL);

    nr_object(nr_object_type_t type, QObject *parent = NULL);
    
    virtual ~nr_object();

    template<typename T> T* object() { return dynamic_cast<T*>(this); } 
    template<typename T> T& object_ref() { return dynamic_cast<T&>(*this); } 

    nr_object_type_t type() { return m_type; };

    virtual void serialize(QDataStream& data_stream) { }

    virtual void deserialize(QDataStream& data_stream) { }

    enum value_type_t
    {
        Invalid = 0,
        Bool = 1,
        Int = 2,
        UInt = 3,
        LongLong = 4,
        ULongLong = 5,
        Double = 6,
        Char = 7,
        Map = 8,
        List = 9,
        String = 10,
        StringList = 11,
        ByteArray = 12,
        BitArray = 13,
        Date = 14,
        Time = 15,
        DateTime = 16,
        Url = 17,
        Locale = 18,
        Rect = 19,
        RectF = 20,
        Size = 21,
        SizeF = 22,
        Line = 23,
        LineF = 24,
        Point = 25,
        PointF = 26,
        Hash = 27,
        Enum = 28
    };

    static value_type_t parser_value_type(const QString& type_str);

protected:
    nr_object_type_t m_type;
};

#endif // NR_OBJECT_H
